/**
 *初始化editModule页面 取要修改的模块数据
 */
function initPage() {
    win.crebtn('editWindow_btnCancel', '关闭', win.close);
    win.crebtn('editWindow_btnSave', '保存', editModule);
    var json = {
        url:contextPath +"/server/base/selectByID.do",
        msg:"数据加载中.....",
        params:{
            "MODULE_DM": myTools.getQueryString("MODULE_DM"),
            "SQLID":"module.selectModuleBY_ID"
        },
        callback:[getModuleCallBack]
    };
    AjaxTools.ajax(json);
    Validator.validate(document.getElementById(("editForm")), 3);
}
function getModuleCallBack(json) {
    myTools.bindForm("editForm", json.data);
}
/**
 *修改模块
 */
function editModule() {
    if (!Validator.validate(document.getElementById(("editForm")), 4))
        return false;
    var orders = document.getElementById("editForm_ORDERS").value;
    var ordersall_sj = document.getElementById("editForm_ORDERSALL_SJ").value;
    if(ordersall_sj!=""){//修改了父模块
        document.getElementById("editForm_ORDERSALL").value = ordersall_sj + "" + LPad(orders,'0',3);
    }else{
        var ordersall = document.getElementById("editForm_ORDERSALL").value;
        //alert(ordersall.substring(0,ordersall.length-3));
        document.getElementById("editForm_ORDERSALL").value = ordersall.substring(0,ordersall.length-3) + "" + LPad(orders,'0',3);
    }
    var json = {
        url:contextPath +"/server/base/update.do",
        msg:"数据保存中.....",
        form:"editForm",
        params:{
            "SQLID":"module.updateModule"
        },
        callback:[editModuleCallBack]
    };
    AjaxTools.ajax(json);
}
function editModuleCallBack(json) {
    var code = json.code;
    if (code == "00") {
        alert(json.data);
        window.parent.parent.getModule();
        win.close('editWindow');
    } else {
        alert(json.data);
    }

}
function onSelectModule(id, name,ordersall) {
    var selectedID = document.getElementById(id).value;
    win.open('ModuleTreeWindow', '模块树', '../../../admin/module/moduleTree.jsp?RTN_ID=' + id + "&RTN_NAME=" + name + "&RTN_ORDERSALL=" + ordersall + "&selectedID=" + selectedID, 250, 350, true, true, '', '', '', 'two');
}